package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class AddOperation implements IOperation {
    public void work(BookList bookList){
        System.out.println("添加图书");
        System.out.println("请输入你要添加的图书名字：");
        Scanner scanner=new Scanner(System.in);
        //如果已经有了该图书，那么如何扩展，存储数量
        String name=scanner.next();//nextLine??
        System.out.println("请输入你要添加的图书的作者：");
        String author=scanner.next();
        System.out.println("请输入你要添加的图书价格：");
        Double price=scanner.nextDouble();
        System.out.println("请输入你要添加的图书类型：");
        String type=scanner.next();
        int curSize=bookList.getUsedSize();
        bookList.setBooks(new Book(name,author,price,type),curSize);
        bookList.setUsedSize(curSize+1);
        System.out.println("添加成功");

    }
}
